# 04-循环读取文件.py
with open('./02-test.txt','r',encoding='utf-8') as file:
    for x in file:
        print(x) # x记录了文件的一行数据
# 2、while 读取文件
# with语法读打开的文件，会自动关闭
with open('./02-test.txt','r',encoding='utf-8') as f:
    while True:
        line = f.readline() 
        if not line:
            break;
        print(line)